.TH ARCHIVE_READ_DATA 3 "February 2, 2012" ""
.SH NAME
.ad l
\fB\%archive_read_data\fP,
\fB\%archive_read_data_block\fP,
\fB\%archive_read_data_skip\fP,
\fB\%archive_read_data_into_fd\fP
\- functions for reading streaming archives
.SH LIBRARY
.ad l
Streaming Archive Library (libarchive, -larchive)
.SH SYNOPSIS
.ad l
\fB#include <archive.h>\fP
.br
\fIla_ssize_t\fP
.br
\fB\%archive_read_data\fP(\fI\%struct\ archive\ *\fP, \fI\%void\ *buff\fP, \fI\%size_t\ len\fP);
.br
\fIint\fP
.br
\fB\%archive_read_data_block\fP(\fI\%struct\ archive\ *\fP, \fI\%const\ void\ **buff\fP, \fI\%size_t\ *len\fP, \fI\%off_t\ *offset\fP);
.br
\fIint\fP
.br
\fB\%archive_read_data_skip\fP(\fI\%struct\ archive\ *\fP);
.br
\fIint\fP
.br
\fB\%archive_read_data_into_fd\fP(\fI\%struct\ archive\ *\fP, \fI\%int\ fd\fP);
.SH DESCRIPTION
.ad l
.RS 5
.TP
\fB\%archive_read_data\fP()
Read data associated with the header just read.
Internally, this is a convenience function that calls
\fB\%archive_read_data_block\fP()
and fills any gaps with nulls so that callers see a single
continuous stream of data.
.TP
\fB\%archive_read_data_block\fP()
Return the next available block of data for this entry.
Unlike
\fB\%archive_read_data\fP(),
the
\fB\%archive_read_data_block\fP()
function avoids copying data and allows you to correctly handle
sparse files, as supported by some archive formats.
The library guarantees that offsets will increase and that blocks
will not overlap.
Note that the blocks returned from this function can be much larger
than the block size read from disk, due to compression
and internal buffer optimizations.
.TP
\fB\%archive_read_data_skip\fP()
A convenience function that repeatedly calls
\fB\%archive_read_data_block\fP()
to skip all of the data for this archive entry.
Note that this function is invoked automatically by
\fB\%archive_read_next_header2\fP()
if the previous entry was not completely consumed.
.TP
\fB\%archive_read_data_into_fd\fP()
A convenience function that repeatedly calls
\fB\%archive_read_data_block\fP()
to copy the entire entry to the provided file descriptor.
.RE
.SH RETURN VALUES
.ad l
Most functions return zero on success, non-zero on error.
The possible return codes include:
\fBARCHIVE_OK\fP
(the operation succeeded),
\fBARCHIVE_WARN\fP
(the operation succeeded but a non-critical error was encountered),
\fBARCHIVE_EOF\fP
(end-of-archive was encountered),
\fBARCHIVE_RETRY\fP
(the operation failed but can be retried),
and
\fBARCHIVE_FATAL\fP
(there was a fatal error; the archive should be closed immediately).
.PP
\fB\%archive_read_data\fP()
returns a count of bytes actually read or zero at the end of the entry.
On error, a value of
\fBARCHIVE_FATAL\fP,
\fBARCHIVE_WARN\fP,
or
\fBARCHIVE_RETRY\fP
is returned.
.SH ERRORS
.ad l
Detailed error codes and textual descriptions are available from the
\fB\%archive_errno\fP()
and
\fB\%archive_error_string\fP()
functions.
.SH SEE ALSO
.ad l
\fBtar\fP(1),
\fBarchive_read\fP(3),
\fBarchive_read_extract\fP(3),
\fBarchive_read_filter\fP(3),
\fBarchive_read_format\fP(3),
\fBarchive_read_header\fP(3),
\fBarchive_read_open\fP(3),
\fBarchive_read_set_options\fP(3),
\fBarchive_util\fP(3),
\fBlibarchive\fP(3),
\fBtar\fP(5)
